package logic

import (
	"context"
	"post/postrpc/postrpc"

	"post/api/internal/svc"
	"post/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type RecordShowLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewRecordShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RecordShowLogic {
	return &RecordShowLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *RecordShowLogic) RecordShow(req *types.RecordShowRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	show, err := l.svcCtx.PostRpc.RecordShow(l.ctx, &postrpc.RecordShowRequest{
		Id:         req.Id,
		UserId:     req.UserId,
		Comment:    req.Comment,
		Title:      req.Title,
		ActivityId: req.ActivityId,
		ClassId:    req.ClassId,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	} else {
		return &types.Response{
			Message: "详情展示成功",
			Code:    200,
			Data:    show,
		}, nil

	}
}
